#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 5;
const int INF = 0x3f3f3f3f;

struct Program {
  int pos, val;
  Program(int p, int v) : pos(p), val(v) {}
};

int dp[MAXN];
int n, s, t[MAXN];

// 表示考虑前i项作业并且第i项作业必须要做，若最长空着的题目条数不大于X,此时至少做题时间
int judge(int x) {
  int K, ans = INF;
  deque<Program> Q; // 维护递增队列，队首是最小值，队尾是最大值
  memset(dp, 0, sizeof(dp));

  for (int i = 1; i <= x + 1; i++) {
    dp[i] = t[i];
    while (Q.size() != 0 && dp[i] < Q.back().val) {
      Q.pop_back();
    }
    Q.push_back(Program(i,dp[i]));
  }
  for (int i = x + 2; i <= n; i++) {
    while (Q.size() != 0 && Q.front().pos < i - x - 1) {
      Q.pop_front();
    }
    dp[i] = Q.front().val + t[i];
    while (Q.size() != 0 && dp[i] < Q.back().val) {
      Q.pop_back();
    }
    Q.push_back(Program(i, dp[i]));
  }
  for (int i = n - x; i <= n; i++) {
    ans = min(ans, dp[i]);
  }
  return ans;
}
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  int Left = 0, Right = n;
  int ans = 0;
  while (Left <= Right) {
    int mid = (Left + Right) >> 1;
    if (judge(mid) <= s) {
      Right = mid - 1;
      ans = mid;
    } else {
      Left = mid + 1;
    }
  }
  cout << ans;
  return 0;
}